package com.atguigu.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version 1.0
 * @Author yanjingren
 * @Date 2021/5/19
 * @Description com.atguigu.gulimall.product.config
 */
@Configuration
public class MyRedissonConfig {

    /**
     * 所有对Redisson的使用都是通过RedissonClient对象
     * @return
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient() {
        // 创建配置
        Config config = new Config();
        config.useSingleServer().setAddress("redis://192.168.238.201:6379");
        // 根据config对象创建出实例
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }
}
